/**
 * Created by hxpeng on 2017/3/24.
 */
(function () {
    'use strict';

    angular.module('App.pages.member')
        .controller('StudentCtrl', StudentCtrl);

    function StudentCtrl(studentId,AppUtils,$scope,MemberModel) {
        if(AppUtils.isUndefinedOrNull(studentId)){
            AppUtils.showTipsTop("请选择一个宝宝操作！");
            AppUtils.goBack();
        }
        var vm =this;
        vm.studentId = studentId;
        vm.studentHadBind = false;


        MemberModel.studentHadBind({memberId:vm.studentId}).$promise.then(function(response){
            if(response.result == 'err'){
                AppUtils.showAlert(response.msg);
            }else{
                if(response.result == 'yse'){
                    vm.studentHadBind = true;
                    console.log(vm.studentHadBind);
                }
            }
        })




        vm.clientType = AppUtils.getClientType();
        if(vm.clientType === "ios"){
            vm.showMenuBoxType = "ios";
            var $iosActionsheet = $('#iosActionsheet');
            var $iosMask = $('#iosMask');
            var hideActionSheet = function() {
                $iosActionsheet.removeClass('weui-actionsheet_toggle');
                $iosMask.fadeOut(200);
            }
            $iosMask.on('click', hideActionSheet);
            $('#iosActionsheetCancel').on('click', hideActionSheet);
            $("#showIOSActionSheet").on("click", function(){
                $iosActionsheet.addClass('weui-actionsheet_toggle');
                $iosMask.fadeIn(200);
            });
        }else{
            vm.showMenuBoxType = "android";
            var $androidActionSheet = $('#androidActionsheet');
            var $androidMask = $androidActionSheet.find('.weui-mask');
            $("#showAndroidActionSheet").on('click', function(){
                $androidActionSheet.fadeIn(200);
                $androidMask.on('click',function () {
                    $androidActionSheet.fadeOut(200);
                });
            });
        }

        $scope.$on('$ionicView.beforeLeave', function(){
            $(".weui-mask").click();
            $("#iosActionsheetCancel").click();
        });

        //
        //$scope.$on('$ionicView.beforeEnter', function (event, viewData) {
        //    viewData.enableBack = true;
        //});
        //
        //var vm = this;
        //vm.parentId = '';
        //
        //var objParams = {};
        ////objParams.memberId = '041DFD58D85D31A478B881F1EBE4ECA9';
        ////objParams.relType = 'father';
        //objParams.memberId = studentId;
        //objParams.relType = 'father';
        //MemberModel.getParentId(objParams).$promise.then(function(response){
        //    if(response.stat == 'err'){
        //        AppUtils.showAlert(response.msg);
        //        AppUtils.goBack();
        //    }else if(response.stat == 'success'){
        //        vm.parentId = response.parentId;
        //    }
        //})
    }
})();